<?php

namespace Nece\Sdk\Coze\Entity;

class EnterMessageList
{
    private $items = array();

    /**
     * 构造函数
     *
     * @author gjw
     * @created 2025-08-05 11:23:21
     *
     * @param EnterMessage $item
     */
    public function __construct(EnterMessage $item)
    {
        $this->addEnterMessage($item);
    }

    /**
     * 添加消息
     *
     * @author gjw
     * @created 2025-08-05 11:23:34
     *
     * @param EnterMessage $item
     * @return void
     */
    public function addEnterMessage(EnterMessage $item)
    {
        $this->items[] = $item;
        return $this;
    }

    /**
     * 转数组
     *
     * @author gjw
     * @created 2025-08-05 11:23:41
     *
     * @return array
     */
    public function toArray()
    {
        $contents = array();
        foreach ($this->items as $item) {
            $contents[] = $item->toArray();
        }

        return $contents;
    }

    /**
     * 转json字符串
     *
     * @author gjw
     * @created 2025-08-05 11:23:55
     *
     * @return string
     */
    public function toJsonString()
    {
        $contents = array();
        foreach ($this->items as $item) {
            $contents = $item->toJsonString();
        }

        return json_encode($contents);
    }

    /**
     * 转字符串
     *
     * @author gjw
     * @created 2025-08-05 11:24:07
     *
     * @return string
     */
    public function toString()
    {
        return $this->toJsonString();
    }
}
